
 <?php 
  	require_once "db.php";
	include "header.php";
	include "classes/user.php";

	
	 $booUsername = 0;
	 $booPass1 = 0;
	 $booPass2 = 0;
	 $booFirstName=0;
	 $booLastName=0;
	 $booEmail=0;
 
 if (isset($_POST["Register"])) {
 	if($_POST["strUsername"] == NULL)
	 	$booUsername = 1;
 	elseif($_POST["strPass1"] == NULL)
 		$booPass1 = 1;
 	elseif($_POST["strPass2"] == NULL)
 		$booPass2 = 1;
	elseif($_POST["strFirstName"] == NULL)
		$booFirstName = 1;
 	elseif($_POST["strLastName"] == NULL)
 		$booLastName = 1;
 	elseif($_POST["strEmail"] == NULL)
 		$booEmail = 1;
	  if($_POST["strPass1"]!=$_POST["strPass2"] ){
	  	$booPass1 = 2;
		$booPass2 = 2;
	  }
	 else{
	 	$name=$_POST["strFirstName"]." ".$_POST["strLastName"];
	 	$mail=$_POST["strEmail"];
	 	$usname=$_POST['strUsername'];
	 	$pss=$_POST['strPass1'];
	 	
	 	$user=new user($name,$mail,$usname,$pss);
	 }
 }
 ?>
 <form action='<?php echo $_SERVER["PHP_SELF"]; ?>' method='post'>
 <table>
 <caption>Registration Form</caption>
 <tr>
 <td> Username:</td>
 <td> <input type="text" name="strUsername" id="strUsername"/>
 <?php if ($booUsername) echo "Please enter a Username!" ?>
 </td>
 
 </tr>
 <tr>
 <td>Password:</td>
 <td> <input type="password" name="strPass1" id="strPass1" />
 <?php if ($booPass1==1) echo "Please enter a password!" ?>
 </td>
 
 </tr>
 <tr>
 <td>Repeat Password:</td>
 <td> <input type="password" name="strPass2" id="strPass2" />
 <?php if ($booPass2==1) echo "Please enter a password!";
 		elseif ($booPass2==2) echo "The passwords must be the same!" ?>
 </td>
 
 </tr>
 <tr>
 <td>Enter First Name:</td>
 <td> <input type="text" name="strFirstName" id="strFirstName" />
 <?php if ($booFirstName) echo "Please enter a First Name!" ?>
 </td>
 
 </tr>
 <tr>
 <td>Enter Last Name:</td>
 <td> <input type="text" name="strLastName" id="strLastName" />
 <?php if ($booLastName) echo "Please enter a Last Name!" ?>
 </td>
 
 </tr>
 <tr>
 <td>Enter Email:</td>
 <td> <input type="text" name="strEmail" id="strEmail" />
 <?php if ($booEmail) echo "Please enter an Email!" ?>
 </td>
 
 </tr>
 <tr>
 <td><p><input type='submit' name='Register' value='Register'/></p></td>
 </tr>
 </table>
 </form>
<?php
	include "footer.php";
?>